import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import tailwindcss from '@tailwindcss/vite'

// https://vite.dev/config/
export default defineConfig({
	plugins: [react(), tailwindcss()],
	server: {
		port: 8888,
		open: true,
		strictPort: true,
		proxy: {
			'/api': {
				target: 'http://localhost:8080',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api/, ''),
			},
		},
	},
	resolve: {
		alias: {
			'@': '/src',
			'@styles': '/src/styles',
			'@assets': '/src/assets',
			'@components': '/src/components',
			'@utils': '/src/utils',
			'@hooks': '/src/hooks',
			'@store': '/src/store',
			'@contexts': '/src/contexts',
		},
	},
	// 配置分包 hash js打包到 static/js 目录 和 static/css 目录
	build: {
		rollupOptions: {
			output: {
				entryFileNames: 'static/js/[name]-[hash].js',
				chunkFileNames: 'static/js/[name]-[hash].js',
				assetFileNames: 'static/css/[name]-[hash].css',
			}
		}
	}


})
